using UnityEngine;
using System.Collections;

public class ThiefMove : MonoBehaviour 
{
	
	public int moveSpeed = 140;  //per second 
	Vector3 computerDirection = Vector3.left; 
	public Transform diamond; 
	Vector3 moveDirection = Vector3.zero; 
	Vector3 newPosition = Vector3.zero; 
	float time = 5;
	// Use this for initialization 
	void Start ()  
	{ 
	 
	} 
	 
	// Update is called once per frame 
	void Update ()  
	{  
		 
		Vector3 newPosition = computerDirection * (moveSpeed * Time.deltaTime);
		newPosition = transform.position + newPosition;  
		newPosition.x = Mathf.Clamp(newPosition.x, -101, 126);  
		transform.position = newPosition; 
		
		if(newPosition.x >= 126)
		{
			newPosition.x = 126;
			computerDirection.x *= -1;
		}
		else if(newPosition.x <= -101)
		{
			newPosition.x = -101;
			computerDirection.x *= -1;
		}
		  
		 int i = 0;
		 while (i < 10)  
		{ 
		    diamond = Instantiate(diamond, newPosition, transform.rotation) as Transform; 
			i++;
		}  
		  
	}  
	
}  
	 
 
